package com.sand.Exception;

import com.sand.result.AppHttpCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.springframework.stereotype.Component;

@Component
@Getter
public class SandException extends RuntimeException{

    private String message;

    private Integer code;

    /**
     * Constructs a new runtime exception with {@code null} as its
     * detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     */
    public SandException(String message, Integer code) {
        this.message = message;
        this.code = code;
    }

    /**
     * Constructs a new runtime exception with {@code null} as its
     * detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     */
    public SandException() {
    }

    /**
     * Constructs a new runtime exception with {@code null} as its
     * detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     */
    public SandException(AppHttpCodeEnum appHttpCodeEnum) {

        this.message = appHttpCodeEnum.getMsg();

        this.code = appHttpCodeEnum.getCode();
    }

    public SandException(AppHttpCodeEnum appHttpCodeEnum , String err) {

        this.message = err;

        this.code = appHttpCodeEnum.getCode();
    }

}
